<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="ISUX">
    <meta name="format-detection" content="telephone=no"/>
    <meta name="layout" content="main_mobile">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>

    <link rel="stylesheet" type="text/css" href="../frozen/css/frozen.css">
    <link rel="stylesheet" type="text/css" href="../css/default.css">

    <title>我捐赠的</title>
    <link rel="stylesheet" type="text/css" href="../css/user_center.css">
    <link rel="stylesheet" type="text/css" href="../venobox/venobox.css" media="screen" />
</head>
<body>
    <section class="ui-container">

        <ul class="ui-tiled ui-info-tiled ui-border-tb">
            <li>
                <div class="num"><em>${projectsTotal}</em>个</div>
                <div>支持项目</div>
            </li>
            <li>
                <div class="num"><em><g:formatNumber number="${donatesTotal}" format="0.00"/></em>元</div>
                <div>共捐善款</div>
            </li>
            <li>
                <div class="num"><em><g:formatNumber number="${fdonatesTotal /100}" format="0.00"/></em>元</div>
                <div>获得配捐</div>
            </li>
        </ul>

        <div class="ui-card-module ui-border-tb">
            <h4 class="ui-border-b">捐赠记录（${donateAll}）</h4>
            
            <ul class="p-list" id="fundpools">
             
               
            </ul>
        </div>
        <div class="ui-line-more" id="more">
             <p  id='week'>加载完成</p>
        </div>
<%--        <div class="banner-wrap">--%>
<%--            <div class="txt-bottom">--%>
<%--            <a href="http://mp.weixin.qq.com/mp/homepage?__biz=MzAxNjM5NzExOQ==&hid=3&sn=e498fbdd2e826943340c0729061ac868#wechat_redirect">了解火堆</a>--%>
<%--            <a href="/scfire/project/qrcode">关注火堆</a><img src="../images/ic-qrcode.png" alt="">--%>
<%--            </div>--%>
<%--            --%>
<%--            <img class="img-bottom" src="../images/logo_and_txt.png" alt="">--%>
<%--        </div>--%>
        
    </section>

    <script src="../frozen/lib/zeptojs/zepto.min.js"></script>
    <script src="../frozen/js/frozen.js"></script>
    
    <script>
        $(function() {
                 $('body').on("click", 'ul.p-list > li .bottom .extra-list-switch', function(){
            	ajaxDonate($(this).find('#tips').val())
                $(this).toggleClass('show').prev('.extra-list').toggleClass('show');
                return false;
            });  
        });
        function ajaxDonate(x){
            
        	 var html="";  
             $.ajax({  
                   type:'get',  
                   dataType:'json',
     	           url:'/scfire/user/userMyDonateDetailByProject?format=json&projectid='+x,  
                   beforeSend:function(){console.log('loading...');},  
                   success:function(data){ 
                       if(data!= null){
                    	   $.each(data,function(i,item){
             	  			   html += " <li class='ui-border-b'>"
                       	   html += " <p>捐款码 "+item.donateNoNew+"<span>"+item.date+"</span></p>"
                       	   if(item.donate_fee==0){
                       		html += "<p>已捐 <em>"+item.money.toFixed(2)+"</em> 元</p>"
                        	}else{
                        		 html += "<p>已捐 <em>"+item.money.toFixed(2)+"</em> 元 ，配捐 <em>"+item.donate_fee.toFixed(2)+"</em>元</p>"
                            }


                       	   
                            
                             html += "</li>"
                             });
             	            //console.log(html);
             	            var y= "projectdonate_"+x.toString();
             	           $('#'+y).empty();
                             $('#'+y).append(html);
                           }                     	                            
                   },  
                   complete:function(){console.log('mission complete.')}  ,
                   error:function(data){
     	              console.log("error")
                 	  $("#week").html('已经到底了');
                   }
       
             }); 


            }


        var finalOffset=5
    	var offset = 0
    	ajaxRead(); 
        function ajaxRead()  
        { 
            var html="";  
            $.ajax({  
                  type:'get',  
                  dataType:'json',
    	          url:'/scfire/user/userMyDonateDetail?format=json&offset='+offset,  
                  beforeSend:function(){console.log('loading...');$("#week").html('加载中...');},  
                  success:function(data){
                	  			$.each(data,function(i,item){
                	  				offset++ 
                	  				 html += " <li>"
                	  				 html += " <a href='/scfire/project/projectDetail?projectid="+item.projectid+"'>"
                	  				 html += "<div class='top' style='background-image:url(/scfire/project/imgRead?img="+item.img+")'>"
           	  					     html += "<div class='h3-box'><h3>"+item.name+"</h3></div>"
                   	  				 html += " <div class='ui-progress'>"
                   	  				 html += "<span style='width:"+item.progress+"%'></span>"
               	  					 html += "</div>"

              	  					  if(item.verified == 'pass'){
              	  	    	        	html +="<div class='status'>募集中</div>"
              	  	        	    }   
              	  	    	        else if(item.verified == 'execute'||item.verified == 'expired'){
              	  	    	        	html +="<div class='status yellow'>已筹完</div>"
              	  	        	    }
              	  	    	        else if(item.verified == 'over'){
              	  	    	        	html +="<div class='status yellow'>已结项</div>"
              	  	        	    } else if(item.verified == 'doing'){
              	  	    	        	html +="<div class='status yellow'>执行中</div>"
              	  	        	    }      	 
              	  	                html +="</div>"
              	  	                html += " </a>"
              	  	                html +="<div class='bottom'>"
              	  	                html +="<div class='infos'>"

              	  	                
            	  	                html +="<div class='infos-l' >捐款<span class='num' style='font-size: 1.2em;'>"+item.donatessize+"</span>次</div>"
            	  	                if(item.projectFDonate==0){
            	  	                	html +="<div class='infos-r'>已捐<span class='num'>"+item.projectDonate.toFixed(2)+"</span>元</div>"
                	  	                }else{
                	  	                	html +="<div class='infos-r'>已捐<span class='num'>"+item.projectDonate.toFixed(2)+"</span>元（配捐<span class='num'>"+item.projectFDonate.toFixed(2)+"</span>元）</div>"
                    	  	                }
              	  	                
              	  	                html +="</div>"
              	  	                
                     	  			html += "<div class='extra-list ui-border-t'>"
                      	  			 html += "<ul id='projectdonate_"+item.projectid+"'>"
                       	  			
                                     html += " </ul>"
                                     html += "</div>"
                                     html += " <div class='extra-list-switch' style=' cursor:pointer' id='test'><input type='hidden' id='tips' value='"+item.projectid +"'></div>"
                                     html += "</div>"
                                     
                                    html += " </li>"
                                });
                	            //console.log(html);
                                $("#fundpools").append($(html));

                                if(data.length<finalOffset){       				
                     				$("#week").html("已经到底了")
                     				$("#week").removeAttr("onclick");
                     				
                         		}else{
                    	            $("#week").html("加载更多")
                    	            $("#week").attr("onclick","ajaxRead()");
                             		}
                                
                  },  
                  complete:function(){console.log('mission complete.')}  ,
                  error:function(data){
    	              console.log("error")
                	  $("#week").html('已经到底了');
                  }
      
            });  
        }  


























        
    </script>
</body>
</html>